package com.edgarli.web.controller.gamble;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.edgarli.common.annotation.Log;
import com.edgarli.common.core.controller.BaseController;
import com.edgarli.common.core.domain.AjaxResult;
import com.edgarli.common.enums.BusinessType;
import com.edgarli.gamble.domain.TLottoHistory;
import com.edgarli.gamble.service.ITLottoHistoryService;
import com.edgarli.common.utils.poi.ExcelUtil;
import com.edgarli.common.core.page.TableDataInfo;

/**
 * 历史大乐透Controller
 * 
 * @author ruoyi
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/gamble/history")
public class TLottoHistoryController extends BaseController
{
    @Autowired
    private ITLottoHistoryService tLottoHistoryService;

    /**
     * 查询历史大乐透列表
     */
    @PreAuthorize("@ss.hasPermi('gamble:history:list')")
    @GetMapping("/list")
    public TableDataInfo list(TLottoHistory tLottoHistory)
    {
        startPage();
        List<TLottoHistory> list = tLottoHistoryService.selectTLottoHistoryList(tLottoHistory);
        return getDataTable(list);
    }

    /**
     * 导出历史大乐透列表
     */
    @PreAuthorize("@ss.hasPermi('gamble:history:export')")
    @Log(title = "历史大乐透", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TLottoHistory tLottoHistory)
    {
        List<TLottoHistory> list = tLottoHistoryService.selectTLottoHistoryList(tLottoHistory);
        ExcelUtil<TLottoHistory> util = new ExcelUtil<TLottoHistory>(TLottoHistory.class);
        util.exportExcel(response, list, "历史大乐透数据");
    }

    /**
     * 获取历史大乐透详细信息
     */
    @PreAuthorize("@ss.hasPermi('gamble:history:query')")
    @GetMapping(value = "/{lottoHistoryId}")
    public AjaxResult getInfo(@PathVariable("lottoHistoryId") Long lottoHistoryId)
    {
        return AjaxResult.success(tLottoHistoryService.selectTLottoHistoryByLottoHistoryId(lottoHistoryId));
    }

    /**
     * 新增历史大乐透
     */
    @PreAuthorize("@ss.hasPermi('gamble:history:add')")
    @Log(title = "历史大乐透", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TLottoHistory tLottoHistory)
    {
        return toAjax(tLottoHistoryService.saveOrUpdate(tLottoHistory));
    }

    /**
     * 修改历史大乐透
     */
    @PreAuthorize("@ss.hasPermi('gamble:history:edit')")
    @Log(title = "历史大乐透", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TLottoHistory tLottoHistory)
    {
        return toAjax(tLottoHistoryService.saveOrUpdate(tLottoHistory));
    }

    /**
     * 删除历史大乐透
     */
    @PreAuthorize("@ss.hasPermi('gamble:history:remove')")
    @Log(title = "历史大乐透", businessType = BusinessType.DELETE)
	@DeleteMapping("/{lottoHistoryIds}")
    public AjaxResult remove(@PathVariable Long[] lottoHistoryIds)
    {
        return toAjax(tLottoHistoryService.deleteTLottoHistoryByLottoHistoryIds(lottoHistoryIds));
    }
}
